package ooday04;
import java.util.Timer;
import java.util.TimerTask;

//匿名内部类----定时器
public class TimerDemo {
    public static void main(String[] args) {

        Timer timer=new Timer();
        int interval=1000;
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("该吃饭啦！！");
            }
        },interval,interval);

















        /*

        Timer timer=new Timer();
        int interval=1000;//设定一个间隔时间(ms)
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("该起床啦");
            }
        }, interval,interval);

         */


      //
    }
}
